<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"
                xmlns:sf="http://www.springframework.org/tags/faces"
                xmlns:cs="http://myfaces.apress.com/custom"
				template="/WEB-INF/layouts/standard.xhtml"
				xmlns:a4j="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich">

	<ui:define name="content">
	
		<div class="section">
			<h2>New Material</h2>
			<h:form id="Material">
				<h:messages errorClass="errors" />				
				<fieldset>
					<div class="field">
						<div class="label">Name:</div>
						<div class="input">
							<sf:clientTextValidator required="true">
								<h:inputText required="true" requiredMessage="Name is required !" id="name" value="#{material.name}"/>
							</sf:clientTextValidator>						
						</div>
					</div>
					<div class="field">
						<div class="label">Type:</div>
						<div class="input">
							<rich:comboBox 	required="true" 
											requiredMessage="Type is required !" 
											id="materialType" 
											value="#{material.materialType}"
											suggestionValues="#{materialTypeController.all}"
											converter="#{materialTypeConverter}"
											>								
							</rich:comboBox>

						</div>
					</div>
					<div class="field">
						<div class="label">Deposit Amount:</div>
						<div class="input">
							<sf:clientTextValidator required="true">
								<h:inputText required="true" requiredMessage="Deposit amount is required !" id="deposit-amount" value="#{material.depositAmount}"/>
							</sf:clientTextValidator>
						</div>
					</div>
					<div class="field">
						<div class="label">Total Count:</div>
						<div class="input">
							<sf:clientTextValidator required="true">
								<h:inputText required="true" requiredMessage="Total count is required !" id="deposit-amount" value="#{material.instances}"/>
							</sf:clientTextValidator>
						</div>
					</div>
					<div class="buttonGroup">
						<sf:validateAllOnClick>
							<h:commandButton id="submit" action="add" value="Add"/>&#160;
						</sf:validateAllOnClick>
						<h:commandButton id="cancel" immediate="true" value="Cancel" action="cancel"/>
					</div>		
				</fieldset>				
				<rich:dataTable value="${materialController.all}" var="aBean">
						<rich:column>
							<f:facet name="header">Name</f:facet>
							<h:outputText value="#{aBean.name}"/>
						</rich:column>
						<rich:column>
							<f:facet name="header">Type</f:facet>
							<h:outputText value="#{aBean.materialType.name}"/>
						</rich:column>			
				</rich:dataTable>
			</h:form>
		</div>
	</ui:define>
</ui:composition>